import Vue from 'vue'
import App from './App.vue'

// 引入element-ui
import ElementUI from 'element-ui';
// 引入element-ui样式
import 'element-ui/lib/theme-chalk/index.css';
// 全局注册组件
Vue.use(ElementUI);

// 引入iview组件
import iView from 'iview';
import 'iview/dist/styles/iview.css'
// 注册iview
Vue.use(iView);

// 引入axios
import axios from 'axios';
// 当前是开发环境,可以忽略
Vue.config.productionTip = false;
// 把axios绑定到vue实例的属性$axios
Vue.prototype.$axios = axios;
// 配置axios的默认链接
axios.defaults.baseURL = "http://localhost:8899"

// 引入路由
import VueRouter from "vue-router";
// 注册路由
Vue.use(VueRouter);
// 引入组件
import Admin from './pages/Admin.vue';
import Login from './pages/Login.vue';
// 这些是商品管理的组件
import GoodsList from './pages/GoodsList.vue';
import GoodsAdd from './pages/GoodsAdd.vue';
import EditGoods from './pages/EditGoods.vue';
// 这些是项目管理的组件
import CategoryList from './pages/CategoryList.vue';
import CategoryAdd from './pages/CategoryAdd.vue';
// 这些是会员管理的组件
import AccountList from "./pages/AccountList.vue";
// 这些是订单管理的组件
import OrderList from "./pages/OrderList.vue";
// 路由配置
const routes = [{path: "/",redirect: "/admin"}, 
                {path: "/login",component: Login,meta: "登录"}, 
                {path: "/admin",component: Admin,redirect: "/admin/goods-list",meta: "后台管理",
                  children: [{path: "goods-list",component: GoodsList,meta: "商品列表"}, 
                             {path: "goods-add",component: GoodsAdd,meta: "增加商品"}, 
                             {path: "edit-goods/:id",component: EditGoods,meta: "编辑商品"}, 
                             {path: "category-list",component: CategoryList,meta: "栏目列表"}, 
                             {path: "category-add",component: CategoryAdd,meta: "新增栏目"}, 
                             {path: "account-list",component: AccountList,meta: "会员列表"}, 
                             {path: "order-list",component: OrderList,meta: "订单列表"}
                            ]
                }]
// 路由对象
const router = new VueRouter({
  routes
})
// 创建根实例
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')